// miniprogram/pages/grade/grade.js
const app = getApp();
const wxcharts = require('../utils/wxcharts-min');

Page({

  /**
   * 页面的初始数据
   */
  data: {
    grade: '',
    altitude: '',
    useTimes:''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function () {
    this.setData({
      grade: app.globalData.grade,
      altitude: app.globalData.iq[0],
      useTimes:app.globalData.useTime
    })

    this.radarShow();
  },
  onShareAppMessage: function (res) {
    return {
      title: '这个智力测试真准，你也来试试吧!',
      path: '/pages/index/index',
      success: function (res) {
        //转发成功
       },
      fail: function (res) {
        // 分享失败
      },
    }
  },

  // 雷达图
  radarShow:function(){
    let radar ={
      animation:true,
      canvasId:'radarCanvas',
      type: 'radar',
      categories: ['知觉辨别'+app.globalData.rightA,'类同比较'+app.globalData.rightB,'比较推理'+app.globalData.rightC,'系列关系'+app.globalData.rightD,'抽象推理'+app.globalData.rightE],
      series:[{
        name:'智力维度（各维度最高12分）',
        data: [app.globalData.rightA,app.globalData.rightB,app.globalData.rightC,app.globalData.rightD,app.globalData.rightE]
      }],
      width:650,
      height:300,
      extra:{
        radar:{
          max: 12 //雷达最大值
        }
      }
    }

    new wxcharts(radar);
  },


  return: function () {
    

    wx.switchTab({
      url: '../index/index',
    })
  },

  info:function(){
    wx.navigateTo({
      url: '../help/help',
    })
  }
})